import { addListener } from "process";
import { Context } from "vm";

/*
 * @Author: cwd
 * @Date: 2022-03-02 17:14:39
 * @LastEditors: cwd
 * @LastEditTime: 2022-06-02 15:17:58
 * @FilePath: \koa2typecsript\src\exception\baseException.ts
 * @Description: 状态码
 * 
 * Copyright (c) 2022 by cwd, All Rights Reserved. 
 */
export class BaseException extends Error {
    // 状态码
    status: number;
    // 提示信息
    message: string;
    // 状态码
    err_code:number;
  }
  
  export class NotFoundException extends BaseException {
    status = 404;
  
    constructor(msg?: string) {
      super();
      this.message = msg || '无此内容';
      this.err_code = 10000
    }
  }
  
  export class UnauthorizedException extends BaseException {
    status = 401;
  
    constructor(msg?: string) {
      super();
      this.message = msg || '尚未登录';
      this.err_code = 10001

    }
  }
  
  export class ForbiddenException extends BaseException {
    status = 403;
  
    constructor(msg?: string) {
      super();
      this.message = msg || '权限不足';
      this.err_code = 10002

    }
    
  }
  
  export class parameterValidationError extends BaseException{
    status = 500;

    constructor( msg?: string) {
    
      super();
      this.message = msg || '参数错误';
      this.err_code = 10003
  
      
    }
  }

  export class youHaveCreat extends BaseException{
    status = 500;
    constructor(msg?: string){
      super();
      this.message = msg || '注册失败'
      this.err_code = 10004

    }
  }
 
